/**
 * 分类模块接口文件
 */

import axios from './request';

/**
 * 分类接口
 */
export interface IClassify {
    id: number;
    name: string;
    sort: number;
    pid: number;
    children?: IClassify[];
}

/**
 * 添加类型
 */
export type AddType = Omit<IClassify, 'id'>;

/**
 * 获取所有
 * @returns 
 */
export const getAll = async (): Promise<IClassify[]> => axios.get('/classify/all');

/**
 * 添加
 * @param model 
 * @returns 
 */
export const add = async (model: AddType) => axios.post('/classify/add', model);

/**
 * 修改
 * @param model 
 * @returns 
 */
export const update = async (model: IClassify) => axios.put('/classify/update', model);

/**
 * 删除
 * @param id 
 * @returns 
 */
export const deleteClass = async (id: number) => axios.delete('/classify/delete/' + id);